<?
class Rule_Invite extends Rule
{
	public $error_message="Данный код не существует или уже использован";
	
	function Check($hash)
	{
		if(!trim($hash[$this->name])) 
		{
			$this->error_message = "Введите код вашего приглашения";
			return false;
		}
		
		if($hash[$this->name]=='8534157')
		{
			$GLOBALS['specialinvite_type'] = 'deti';
			return true;
		}
		if($hash[$this->name]=='8534154')
		{
			$GLOBALS['specialinvite_type'] = 'deti2';
			return true;
		}
		if($hash[$this->name]=='8534172')
		{
			$GLOBALS['specialinvite_type'] = 'deti3';
			return true;
		}
		if($hash[$this->name]=='8534348')
		{
			$GLOBALS['specialinvite_type'] = 'deti4';
			return true;
		}
		if($hash[$this->name]=='8539372')
		{
			$GLOBALS['specialinvite_type'] = 'deti5';
			return true;
		}
		if($hash[$this->name]=='1938392')
		{
			$GLOBALS['specialinvite_type'] = 'week';
			return true;
		}
		
		
		if($hash[$this->name]=='7114238')
		{
			$GLOBALS['specialinvite_type'] = 'bt';
			return true;
		}
		if($hash[$this->name]=='9312741')
		{
			$GLOBALS['specialinvite_type'] = 'svitmam';
			return true;
		}
		if($hash[$this->name]=='3962045')
		{
			$GLOBALS['specialinvite_type'] = 'kroha';
			return true;
		}
		
		/*
		if($GLOBALS['specialinvite_type']=='brevi')
		{
			return true;
		}
		if($GLOBALS['specialinvite_type']=='weleda')
		{
			return true;
		}
		*/
		if($GLOBALS['specialinvite_type'])
		{
			return true;
		}
		
		
		if(DB::scalarSelect("select id from invite where hash=?", $hash[$this->name])) return true;
		
		return false;
	}
}